﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ZX.WebApp.WorkFlow
{
    public partial class ErrorLogs : System.Web.UI.Page
    {
        //调用流程服务接口实例
        CrmWorkFlowService.WorkFlowServiceClient workFlowServiceClient = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //实例化流程服务接口
                workFlowServiceClient = new CrmWorkFlowService.WorkFlowServiceClient();
                if (Request["Statues"] == "1")
                {
                    if (Request["WorkFlowInstanceId"] != null)
                    {
                        DataTable dt = workFlowServiceClient.GetWorkFlowErrorLogs(Request["WorkFlowInstanceId"].ToString());
                        gvErrorLogs.DataSource = dt;
                        gvErrorLogs.DataBind();
                    }
                }
                else 
                {
                    if (Request["WorkTaskInstanceId"] != null && Request["WorkFlowInstanceId"] != null && Request["logType"] != null)
                    {
                        InDate(Request["logType"].ToString(), Request["WorkTaskInstanceId"].ToString(), Request["WorkFlowInstanceId"].ToString());
                    }
                }
            }
        }
        private void InDate(string logType, string WorkTaskInstanceId, string WorkFlowInstanceId)
        {
            try
            {
                int flows = workFlowServiceClient.GetWorkFlowErrorLogsColse(logType, WorkTaskInstanceId, WorkFlowInstanceId);
                HttpContext.Current.Response.Write("1");
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("0");
                throw ex;
            }
        }
    }
}